import React, { Component } from 'react'
import { Switch, Route, Redirect } from "react-router-dom"

// 懒加载
let Register =React.lazy(()=>import("./containers/Register/Register")) 
let Login =React.lazy(()=>import("./containers/Login/Login")) 
let Index =React.lazy(()=>import("./containers/Index/Index")) 
let Detail =React.lazy(()=>import("./containers/Detail/Detail")) 
let PrivateRoute = React.lazy(()=>import("../src/utils/PrivateRoute"))

export default class App extends Component {
  render() {
    return (
      <React.Suspense fallback={<div>正在加载...</div>}>
        <Switch>
          <Route path="/register" component={Register}></Route>
          <Route path="/login" component={Login}></Route>
          <PrivateRoute path="/index" component={Index}></PrivateRoute>
          <PrivateRoute path="/detail/:id" component={Detail}></PrivateRoute>
          <Redirect to="/register"></Redirect>
        </Switch>
      </React.Suspense>
    )
  }
}
